package com.ysq.www.api.front.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ysq.www.api.front.entity.Press;
import com.ysq.www.api.front.mapper.PressMapper;
import com.ysq.www.api.front.service.IPressService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 新闻表 服务实现类
 * </p>
 *
 * @author dql
 * @since 2020-08-07
 */
@Service
public class PressServiceImpl extends ServiceImpl<PressMapper, Press> implements IPressService {

    @Autowired
    private PressMapper pressMapper;

    /**
     * 分页查询今日头条新闻
     * @param pageNumber 页码
     * @param pageSize 页大小
     * @return IPage
     */
    @Override
    public IPage<Press> selectPressByPage(Integer pageNumber, Integer pageSize) {
        QueryWrapper<Press> wrapper = new QueryWrapper<>();
        wrapper.eq("status",0).orderByDesc("release_time");
        Page<Press> page = new Page<>(pageNumber,pageSize);
        IPage<Press> pPage = pressMapper.selectPage(page, wrapper);
        return pPage;
    }
}
